# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Neil Darlow <neil@darlow.co.uk>
# Contributor: Jens Maucher <defcon@archlinux.us>

pkgname=freehdl
pkgver=0.0.8
pkgrel=13
pkgdesc='An open-source (C++ generating) VHDL simulator'
arch=('loong64' 'x86_64')
url='http://freehdl.seul.org'
license=('GPL')
depends=('perl')
optdepends=('gtkwave: to view output when run standalone')
options=('libtool')
source=("https://downloads.sourceforge.net/qucs/$pkgname-$pkgver.tar.gz"
	"build-fix.patch"
	"cpp-modern.patch"
	"acl-NULL-check.patch"
	"declarative_region.patch"
	"gentoo-qa.patch"
	"gvhdl_tag_command.patch")
sha256sums=('7f0978f8252329450de43e98c04c15fdd8a3f2bdc5ca91f75f8f5dd280c6ed84'
            '08d49fc621d48099afcbe42c99ba25474409dbe5c16748a1cd01f50c0e1bae25'
            '86f35a7cb915bab69763808c59b295c15e198bb21f6383214027dd9ea7490867'
            'e59323840387514be8300f088051e60e39e73b50383958c81c19c4e4575b0094'
            '5b4b23f98b666818a0d8bd484e899960c1951631c8a21928a072e19b3c1fc6e6'
            'bf1ed53f2b83e91e580c5300d157322cf70aeb955685fa91b1358f474efef5ff'
            'a7e441b42f3eae61eaff681713094fbe332d3ab8685e215e21c975eb8af60036')

prepare() {
  cd "${srcdir}"/$pkgname-$pkgver
  rm ieee/math_real.cc \
     ieee/numeric_bit.cc \
     ieee/numeric_std.cc \
     ieee/std_logic_1164.cc \
     ieee/std_logic_arith.cc \
     ieee/std_logic_signed.cc \
     ieee/std_logic_unsigned.cc \
     ieee/vital_timing.cc

  #patch -p1 -i "$srcdir"/build-fix.patch
  patch -p1 -i "$srcdir"/cpp-modern.patch
  patch -p1 -i "$srcdir"/acl-NULL-check.patch
  patch -p1 -i "$srcdir"/declarative_region.patch
  patch -p1 -i "$srcdir"/gentoo-qa.patch
  patch -p1 -i "$srcdir"/gvhdl_tag_command.patch
}

build() {
  cd "${srcdir}"/$pkgname-$pkgver
  CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=1" ./configure --prefix=/usr
  make
}

package() {
  cd "${srcdir}"/$pkgname-$pkgver
  make DESTDIR="${pkgdir}" install
}
